﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.UserInfoCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.UserInfoHandlers
{
    public class UserInfoUpdateStateHandler : IRequestHandler<UserInfoUpdateStateCommand, Results<int>>
    {

        private readonly IUserInfoService userInfoService;
        private readonly IMapper mapper;


        public UserInfoUpdateStateHandler(IUserInfoService userInfoService, IMapper mapper)
        {
            this.userInfoService = userInfoService;
            this.mapper = mapper;
        }
        /// <summary>
        /// 修改用户状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(UserInfoUpdateStateCommand request, CancellationToken cancellationToken)
        {
           
            var res = await userInfoService.UpdateUserState(request.UserId, request.UserState);
            return  Results<int>.DataResult(res);


        }
    }
}
